package hibernate;

import hibernate.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

@Slf4j
// Spring启动类
public class Main {
    public static void main(String[] args) throws InterruptedException {
        // 从AppConfig类读取IoC配置并创建IoC容器
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        // 获取UserService实例
        UserService userService = context.getBean(UserService.class);
        // 插入数据库
        User user = userService.register("test@test.com","test","test");
        System.out.println(user);
        user = userService.login("test@test.com","test");
        System.out.println(user);
        // 二次插入，验证AOP是否工作
        user = userService.register("test@test.com","test","test");
        System.out.println(user);
    }
}
